#@head() #@header()
<title>融资需求管理</title>
#@aside("marketing")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
			#@appmenu("appcarousel")
            
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				 <button type="button" onclick="window.location.href='#(path)/admin/page/marketing-addcarousel'" class="btn btn-block btn-info" style="width:120px;float:left;margin-top:10px;margin-right:20px;">新建轮播图</button>
				<div class="box-body">
					<table id="example1" class="table table-striped">
						<thead>
							<tr>
								<th>轮播图ID</th>
								<th>排序</th>
								<th>轮播图标题</th>
								<th>创建时间</th>
								<th>链接地址</th>
								<th>图片地址</th>
								<th>状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="newslist">
							
							
						</tbody>
					</table>
				</div>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id="newslist1"><a href="#">首页</a></li>
					<li id="newslist2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="newslist5"></span>页 共<span id="newslist6"></span>页</a></li>
					<li id="newslist3"><a href="#">下一页</a></li>
					<li id="newslist4"><a href="#">尾页</a></li>
				  </ul>
				</div>
              </div>
            </div>
            <!-- /.tab-content -->
          </div>
		  
	</section>
</div>
#@footer()
<script id="newslistall" type="text/x-jquery-tmpl">
	<tr>
		<td>${id}</td>
		<td>${dsporder}</td>
		<td>${name}</td>
		<td>${create_time}</td>
		<td>${link}</td>
		<td>${pic}</td>
		<td>${status}</td>
		<td>
			<div class="btn-group">
			  <div class="btn-group">
			  <button onclick="window.location.href='#(path)/admin/page/marketing-changecarou?id=${id}&obj=appcarousel'" type="button" class="btn btn-info">修改</button>
			  <button pass="${id}" type="button" class="btn btn-warning pass">${status2}</button>
			  <button pass="${id}" type="button" class="btn btn-danger del">删除</button>
			</div>
			</div>
		</td>
	</tr>
</script>
<script>
var totalPage = 1;
var pageNumber = 1;
 $(document).ready(function(){
	totalPage = 1;
	pageNumber = 1;
	$("#newslist").empty();
	newslist(1);
	$("#newslist5").html(pageNumber);
});
$("#newslist1").click(function(){
	$("#newslist").empty();
	newslist(1);
	pageNumber = 1;
	$("#newslist5").html(pageNumber);
});
$("#newslist2").click(function(){
	if(pageNumber==1){
		alert("当前页是首页!");
	}else{
	$("#newslist").empty();
	pageNumber = pageNumber-1;
	newslist(pageNumber);
	$("#newslist5").html(pageNumber);
	}
});
$("#newslist3").click(function(){
	if(pageNumber==totalPage){
		alert("当前页是尾页!");
	}else{
	$("#newslist").empty();
	pageNumber = pageNumber +1;
	newslist(pageNumber);
	$("#newslist5").html(pageNumber);
	}
});
$("#newslist4").click(function(){
	$("#newslist").empty();
	newslist(totalPage);
	pageNumber = totalPage;
	$("#newslist5").html(pageNumber);
});
function newslist(page){
		$.getJSON("/slider/list?token=#(session.token??)&page="+page+"&size=12", function(userli) {
			 
			totalPage = userli.data.totalPage;
			$("#newslist6").html(totalPage);
			$.each(userli.data.list, function(i, item){ 
				if(item.status=="disable"){
					var status = "下线";
					var status2 = "上线";
				}else if(item.status=="enable"){
					var status = "上线";
					var status2 = "下线";
				}
				var newslist = {status2:status2,name:item.name,status:status,id:item.id,type:item.type,create_time:item.create_time,dsporder:item.dsporder,link:item.link,pic:item.pic};
				$("#newslistall").tmpl(newslist).appendTo('#newslist');
			});
			$(".pass").click(function(){
				var idval = $(this).attr("pass");
				var bb="";
				var aa=$(this).html();
				 
				if(aa=="上线"){ bb = "enable"}else if(aa=="下线"){ bb = "disable"}
				 
				 
				$.getJSON("/slider/switchStatus?token=#(session.token??)&id="+idval+"&status="+bb, function(data) {
					if(data.code=='success'){
						layer.msg(data.msg, {icon:1},function(){
							location.href="#(path)/admin/page/marketing-appcarousel"
						});
					}else if(data.code=='error'){
						layer.msg(data.msg, {icon:2});
					}
				});
			});
			$(".del").click(function(){
				var idval = $(this).attr("pass");
				layer.confirm('确定要删除吗？', {
				  btn: ['十分确定','取消'] //按钮
				}, function(){
					$.getJSON("/slider/del?token=#(session.token??)&id="+idval, function(data) {
						if(data.code=='success'){
							layer.msg(data.msg, {icon:1},function(){
								location.href="#(path)/admin/page/marketing-appcarousel"
							});
						}else if(data.code=='error'){
							layer.msg(data.msg, {icon:2});
						}
					});
				});
			});
		});	 
		
	}

</script> 

</body>
</html>

